﻿using System;
using System.Runtime.InteropServices;

namespace Yinyue200.COMInterop
{

    //The IMemoryBufferByteAccess interface inherits from the IUnknown interface. IMemoryBufferByteAccess also has these types of members:

    /// <summary>
    /// Provides access to an IMemoryBuffer as an array of bytes.
    /// </summary>
    [ComImport]
    [Guid("5B0D3235-4DBA-4D44-865E-8F1D0E4FD04D")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public unsafe interface IMemoryBufferByteAccess
    {
        //If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
        //When MemoryBuffer::Close is called, the code using this buffer should set the value pointer to null.
        /// <summary>
        /// Gets an IMemoryBuffer as an array of bytes. 
        /// </summary>
        /// <param name="buffer">A pointer to a byte array containing the buffer data.</param>
        /// <param name="capacity">The number of bytes in the returned array</param>
        void GetBuffer(out byte* buffer, out uint capacity);
    }
}
